<?php
namespace common;
use yii;
/**
 * Created by PhpStorm.
 * User: 张
 * Date: 2015/9/15
 * Time: 22:53
 */
class Session {
    //生成session，本操作的目前只能用于单用户单客户端登陆
    public static function addSession($admin_id){
        $session=Yii::$app->session;
        if($session->isActive){
            //判断session是否开启
        }else{
            $session->open();
        }
        /*$session[$admin_id] = [
            'islogin' => 101,
            'lifetime' => 10,
        ];*/
        //首先清空session
        self::deleteSession();
        //然后添加当前用户的session
        $session->set('admin_id',$admin_id);
        $session->set('islogin','101');
    }
    //检测session
    public static function getSession(){
        $session=Yii::$app->session;
        return $session->get('islogin');
    }
    //删除session
    public static function deleteSession(){
        $session=Yii::$app->session;
        $session->destroy();
    }
}
?>
